import { Component, Vue, Prop } from 'vue-property-decorator';
import {TreeSelect} from 'ant-design-vue';

@Component({
  components: {
    rendom: {
      functional: true,
      props: {
        render: {
          required: true
        },
        data: {
          required: true,
        },
        index: {
          required: false,
        }
      },
      render(h: any, context: any) {
        const { data, render, index } = context.props;
        return render(h, data, index)
      }
    }
  }
})
export default class AppFormModel extends Vue {
  @Prop({
    required: false,
    default: () => { },
  }) form!: any;
  @Prop({
    required: false,
    default: () => [],
  }) formItems!: any[]
  @Prop({
    required: false,
    default: () => { },
  }) formRule!: {}
  @Prop({
    required: false,
    default: () => { },
  })
  parentEl!: any;
  showCheckedStrategy: any = (TreeSelect as any).SHOW_PARENT;

  resetFields() {
    this.formModel.resetFields();
  }

  get formModel(): any {
    return this.$refs.formModel;
  }

  isShow(item: any) {
    if (!Object.prototype.hasOwnProperty.call(item, 'show')) return true;
    if (typeof (item.show) === 'string') return this.parentEl[item.show];
    return item.show;
  }
}